#!/usr/bin/env bash
# Find which packages have diffrrent project name on ABF and SRPM name
set -e
csv="$PWD"/names-diff.csv

wget -qO- https://abf.rosalinux.ru/api/v1/platforms/4084/projects | grep '^import/' | sort -u | awk -F 'import/' '{print $NF}' | while read -r line
do
	pushd "$line" || continue
	srpm="$(rpmspec -q --srpm --queryformat='%{name}' *.spec || :)"
	project="$(pwd | awk -F '/' '{print $NF}')"
	if [ "$srpm" != "$project" ] ; then
		echo "${srpm};${project}" >> "$csv"
	fi
	popd
done
